# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

# class Solution:
#     def inorderTraversal(self, root):
#         if not root:
#             return []
#         stark = []
#         self.traceral(root,stark)
#         return stark
#     def traceral(self,root,stark):
#         if not  root:
#             return
#         self.traceral(root.left,stark)
#         stark.append(root.val)
#         self.traceral(root.right,stark)


# Definition for a binary tree node.
# class TreeNode:
#     def __init__(self, x):
#         self.val = x
#         self.left = None
#         self.right = None

class Solution:
    def inorderTraversal(self, root):
        stark = []
        res = []
        while stark or root:
            if root:
                stark.append(root)
                root = root.left
            else:
                temp = stark.pop()
                res.append(temp.val)
                root = temp.right
        return res




